#include "stdafx.h"
#include "tilegroup.h"

namespace Graphics {

TileGroup::TileGroup(uint minX, uint minY, uint maxX, uint maxY)
{
    renewBoxImpl(minX, minY, maxX, maxY);
}

void TileGroup::renewBox()
{
    uint minX = _box.getMinCoord().x;
    uint minY = _box.getMinCoord().y;
    uint maxX = _box.getMaxCoord().x;
    uint maxY = _box.getMaxCoord().y;
    renewBoxImpl(minX, minY, maxX, maxY);
}

void TileGroup::renewBoxImpl(uint minX, uint minY, uint maxX, uint maxY)
{
    double minHeight = 1e10;
    double maxHeight = -1e10;
    for (uint x = minX; x <= maxX; ++x)
    {
        for (uint y = minY; y <= maxY; ++y)
        {
            //double height = _map->at(x, y).edge(0, 0);
            //if (height < minHeight)
            //    minHeight = height;
           // if (height > maxHeight)
           //     maxHeight = height;
        }
    }
    _box = GLC::BoundingBox(vec3f(minX, minY, minHeight),
                            vec3f(maxX, maxY, maxHeight));
}

} // namespace Graphics
